package com.example.demo.service;

import com.example.demo.entity.Message;
import com.example.demo.mapper.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageService {

    @Autowired
    private MessageMapper messageMapper;

    // 保存消息
    public void saveMessage(Message message) {
        messageMapper.insertMessage(message);
    }

    // 获取消息列表
    public List<Message> getMessageList(Long receiverId) {
        return messageMapper.findMessagesByReceiverId(receiverId);
    }
}
